module windump.plugins.trademanager.trademanager;

import std.file;
import std.regexp;
import std.string;
import std.path;
import std.stdio;
version(WD_Console) import std.stdio;

import windump.scanning.detector;
import windump.registry;


private const string[] RegKeys = [ 
    `SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\TradeManager`,
    `SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\阿里旺旺(贸易通版)`,
    `SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\阿里旺旺(贸易通版)V5.1`
];

private const string RegexpString = `\x00\x00[^0x00]{4}([a-zA-z0-9]+)\x00([^\x00]+)\x00`;
private const uint DBBeginOffset = 0x3000;

class TradeManagerDetector : Detector!(TradeManagerDetector, "im/trade_manager", "table")
{
    public this()
    {
    }

    private string getTMPath(string keyPath)
    {
        Key k = Registry.localMachine.openSubkey(keyPath);//, 
//                REGSAM.KEY_READ | REGSAM.KEY_QUERY_VALUE);
        scope(exit) k.close();
        string path = k.getValue("UninstallString").value_SZ();
		path = tolower(path);
        int pos = std.string.find(path, "\\unwise.exe");
		if(pos >= 0) 
			path = path[0 .. pos];

        return path;
    }

    private ResultItem decryptEntry(string keyPath)
    {            
        string configPath = getTMPath(keyPath) ~ `\users\system\config.db`;
        string content = cast(string)read(configPath);
        content = content[DBBeginOffset .. $];
        
        foreach(m; RegExp(RegexpString).search(content))
        {
            string pass = decrypt(m.match(1), m.match(2));
            ResultItem item;
            item.host = "unknown";
            item.provider = name();
            item.account = m.match(1);
            item.password = pass;
            writefln(item.password);
            return item;
        }
    }    

    public override ResultItem[] update()
    {
        ResultItem[] ret;

        foreach(keyPath; RegKeys)
        {
            try
            {
                ret ~= decryptEntry(keyPath);
            }
            catch(Exception e)
            {
                continue; // 有错误就测试下一次
            }
        }
        writefln(ret.length);

        return ret;
    }
}

//下面的程序是我有史以来最自豪的汇编调试记录了，用 OllyDbg 跟了整整两天


private string decrypt(string userid, string enc)
{
    uint sum = 0;
    foreach(char c; userid)
        sum += c;

    sum %= 0x0A;

    string pass;
    foreach(char c; enc)
    {
        uint pos = sum * 0x118;
        pos += c - 1;
        char d = MapTable[pos];
        pass ~= d;
    }
    return pass;
}


static const string MapTable = [
//mod=0                  
0x29, 0xEE, 0xD9, 0xA5, 0xE3, 0xFB, 0x9B, 0x84, 0xC2, 0x87, 0xE7, 0xC8, 0xB0, 0x5F, 0xA1, 0xA4,
0xB6, 0xDD, 0x9C, 0xBE, 0x3E, 0xE2, 0xF3, 0x54, 0x85, 0x92, 0x05, 0x3C, 0xBC, 0x55, 0x37, 0xBB,
0xFC, 0x33, 0x7A, 0xB8, 0x2E, 0xC0, 0xED, 0xC4, 0xCB, 0x0D, 0xB9, 0xC7, 0x13, 0x7F, 0x06, 0x99,
0x30, 0xD5, 0xBF, 0x8D, 0xDA, 0x49, 0x0B, 0x21, 0x4B, 0x65, 0xFF, 0xDF, 0x6D, 0x3B, 0xE0, 0x38,
0xD1, 0x7D, 0xFE, 0x25, 0x8E, 0x76, 0x98, 0x95, 0x09, 0xC9, 0x9F, 0x51, 0x52, 0x04, 0xAF, 0x15,
0xF4, 0x1C, 0xD0, 0x58, 0x34, 0x1B, 0x5D, 0x77, 0x27, 0x97, 0xCA, 0x10, 0xA2, 0xAC, 0x57, 0xB4,
0xC1, 0xCE, 0x91, 0x5B, 0x1A, 0xD6, 0x44, 0x69, 0x9D, 0x53, 0x8A, 0x6B, 0x79, 0xC3, 0xB5, 0xDC,
0xE8, 0xAE, 0xE1, 0xBD, 0xCD, 0x19, 0x35, 0x67, 0x39, 0x0F, 0x86, 0xCF, 0x68, 0xA0, 0x8B, 0x3A,
0x11, 0x62, 0x2A, 0x71, 0x40, 0xE5, 0xE4, 0x03, 0x89, 0x56, 0xB1, 0x74, 0xB2, 0xF1, 0x50, 0xEF,
0x41, 0x7B, 0xDE, 0xD2, 0x5C, 0xF2, 0xEB, 0x1F, 0xB3, 0x70, 0xCC, 0xA3, 0xA8, 0xEC, 0x72, 0x66,
0xDB, 0x2B, 0xF7, 0x78, 0x36, 0x20, 0x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, 0x7B, 0xE2, 0x75,
0x41, 0xB8, 0xBD, 0x2E, 0x66, 0xE3, 0x7E, 0xB7, 0xA4, 0xE7, 0x14, 0x58, 0xEC, 0xD3, 0x31, 0x93,
0x4B, 0xDF, 0xB3, 0xA0, 0x79, 0x94, 0xCC, 0x1C, 0x8F, 0x0A, 0xD5, 0x02, 0x84, 0x74, 0x29, 0xF8,
0x63, 0x2F, 0x35, 0x20, 0x7C, 0xCD, 0x36, 0x57, 0x81, 0x38, 0x39, 0x25, 0xE0, 0x72, 0xFC, 0x80,
0xE9, 0x30, 0xC8, 0x21, 0x4A, 0xDC, 0xC7, 0xBC, 0x43, 0x10, 0x06, 0x98, 0xA9, 0x07, 0x16, 0xA8,
0x2B, 0x0E, 0x44, 0x9F, 0xF0, 0x68, 0x4C, 0x6B, 0xAA, 0xA6, 0x61, 0x32, 0x5A, 0x3D, 0x82, 0xA2,
0xF9, 0x56, 0xC3, 0x3C, 0xD7, 0x0D, 0xF1, 0x0C, 0x0F, 0xDE, 0x86, 0xB0, 0xFF, 0xDB, 0x96, 0x09,
0xC4, 0x89, 0x45, 0x71, 0x19, 0xE5, 0xC9, 0xFE, 0x46, 0x6D, 0x2D, 0xD2, 0xB1, 0x49, 0xDD, 0xBA,
0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x23, 0x00, 0x23, 0x00, 0x81, 0x07, 0x18, 0x01,                          

//mod=5
0x86, 0x15, 0xE0, 0x7B, 0x18, 0xA2, 0xCE, 0xF4, 0xF7, 0x57, 0xAF, 0x45, 0x38, 0x3C, 0x91, 0x06,
0xE4, 0xB9, 0x2E, 0xE6, 0xD4, 0xF1, 0x78, 0x87, 0xEC, 0xEA, 0x0F, 0x95, 0xC0, 0xFD, 0xC5, 0x2B,
0x53, 0x21, 0xEE, 0x32, 0x49, 0x24, 0x8C, 0x71, 0x66, 0xDD, 0xF9, 0x72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0x5E, 0xD9, 0x14, 0x63, 0x5D, 0x50, 0xB0, 0x19, 0xBB, 0x68, 0x13, 0x01, 0xA3, 0x4A, 0x67,
0x8B, 0x02, 0x58, 0x85, 0x47, 0x0C, 0x16, 0xFF, 0x69, 0x9C, 0x62, 0x64, 0x30, 0x9F, 0xE1, 0xBA,
0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x23, 0x00, 0x23, 0x00, 0xA4, 0x07, 0x18, 0x01,                        

//mod=6
0xB8, 0x30, 0x7C, 0xBF, 0x38, 0x84, 0x1E, 0xED, 0x4A, 0x04, 0x97, 0x28, 0x0D, 0xE3, 0x5E, 0xE1,
0x24, 0xBE, 0xD0, 0xE0, 0xD2, 0x72, 0xB6, 0x0A, 0xCF, 0xCC, 0x9B, 0x94, 0x48, 0xE8, 0xC7, 0x1D,
0x9E, 0x5D, 0xCD, 0x26, 0xDA, 0xEA, 0x86, 0x15, 0xA6, 0xCB, 0x17, 0x4F, 0xB0, 0xB9, 0x2E, 0x0F,
0xEE, 0xEF, 0x8C, 0x4E, 0x2D, 0x80, 0x9A, 0x0E, 0xC8, 0xBB, 0xB5, 0xCA, 0xAE, 0xF7, 0xE5, 0xB7,
0xE7, 0x4C, 0x3D, 0x34, 0x63, 0x76, 0xFE, 0x16, 0x79, 0x89, 0x2B, 0x42, 0x51, 0x6E, 0xE2, 0xD4,
0x39, 0x5A, 0x4D, 0x22, 0x06, 0x09, 0xF0, 0x3A, 0xD3, 0xFF, 0xC1, 0x31, 0xEB, 0x41, 0x3C, 0x49,
0x1A, 0x59, 0x6F, 0xE6, 0xD1, 0x60, 0x88, 0xDF, 0x2A, 0x77, 0x64, 0x43, 0xC6, 0x96, 0x52, 0xBA,
0x3E, 0x98, 0xAF, 0x14, 0x7F, 0x12, 0x99, 0x95, 0x78, 0x18, 0xCE, 0x05, 0x46, 0xA8, 0x9D, 0xE4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